<?php
/**
 +------------------------------------------------------------------------------
 * Run Framework 数据库访问接口
 +------------------------------------------------------------------------------
 * @date    2017-06
 * @author  Jimmy Wang <1105235512@qq.com>
 * @version 1.0
 +------------------------------------------------------------------------------
 */
interface IDataSource
{	
	/**
	 +----------------------------------------------------------
	 * 获得一条查询记录
	 +----------------------------------------------------------
	 * @access public 
	 +----------------------------------------------------------
	 * @param  string  $sql  SQL指令
	 +----------------------------------------------------------
	 * @return array
	 +----------------------------------------------------------
	 */	
	public function getRow($sql);
	
	/**
	 +----------------------------------------------------------
	 * 获得多条查询记录
	 +----------------------------------------------------------
	 * @access public 
	 +----------------------------------------------------------
	 * @param  string  $sql  SQL指令
	 +----------------------------------------------------------
	 * @return array
	 +----------------------------------------------------------
	 */
	public function getRows($sql);

	/**
	 +----------------------------------------------------------
	 * 执行SQL语句
	 +----------------------------------------------------------
	 * @access public 
	 +----------------------------------------------------------
	 * @param  string $sql  sql指令
	 +----------------------------------------------------------
	 * @return mixed
	 +----------------------------------------------------------
	 */
	public function query($sql);

	/**
	 +----------------------------------------------------------
	 * 添加数据(辅助方法)
	 +----------------------------------------------------------
	 * @access public
	 +----------------------------------------------------------
	 * @param  string  $table  表名
	 +----------------------------------------------------------
	 * @param  array   $arr    插入的数据(键值对)
	 +----------------------------------------------------------
	 * @return mixed
	 +----------------------------------------------------------
	 */
	public function insert($table,$arr=array());

	/**
	 +----------------------------------------------------------
	 * 更新数据(辅助方法)
	 +----------------------------------------------------------
	 * @access public
	 +----------------------------------------------------------
	 * @param  string  $table  表名
	 +----------------------------------------------------------
	 * @param  array   $arr    更新的数据(键值对)
	 +----------------------------------------------------------
	 * @param  mixed   $where  条件
	 +----------------------------------------------------------
	 * @param  array   $add_self  字段加减
	 +----------------------------------------------------------
	 * @return mixed
	 +----------------------------------------------------------
	 */
	public function update($table,$arr=array(),$where='');

	/**
	 +----------------------------------------------------------
	 * 删除数据(辅助方法)
	 +----------------------------------------------------------
	 * @access public
	 +----------------------------------------------------------
	 * @param  string  $table  表名
	 +----------------------------------------------------------
	 * @param  mixed   $where  条件
	 +----------------------------------------------------------
	 * @return mixed
	 +----------------------------------------------------------
	 */
	public function delete($table,$where='');
	
	
	/**
	 +----------------------------------------------------------
	 * 开启事物(辅助方法)
	 +----------------------------------------------------------
	 * @access public
	 +----------------------------------------------------------
	 * @param  int  $isXA  是否开启分布式事务
	 +----------------------------------------------------------
	 * @return mixed
	 +----------------------------------------------------------
	 */
	public function startTrans();
	
	/**
	 +----------------------------------------------------------
	 * 事物回滚(辅助方法)
	 +----------------------------------------------------------
	 * @access public
	 +----------------------------------------------------------
	 * @return mixed
	 +----------------------------------------------------------
	 */
	public function rollback();
	
	/**
	 +----------------------------------------------------------
	 * 事物提交(辅助方法)
	 +----------------------------------------------------------
	 * @access public
	 +----------------------------------------------------------
	 * @return mixed
	 +----------------------------------------------------------
	 */
	public function commit();

}
?>